"use strict";
cc._RF.push(module, 'ec4f88zKgtOvIzGBupqlhI1', 'season_item_node');
// scripts/season_item_node.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("AD"),
    _ = cc._decorator,
    c = _.ccclass,
    d = _.property,
    h = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.level_label = null, t.general_award_type_node = null, t.general_award_num = null, t.general_get_award_btn = null, t.general_get_over = null, t.general_mask = null, t.special_award_type_ndoe = [], t.special_award_num = [], t.special_get_award_btn = null, t.special_get_over = null, t.special_mask = null, t.red_node = null, t.season_index = -1, t.season_award_info = null, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    e.prototype.initView.call(this);
  }, t.prototype.addEvent = function () {
    this.attachEvent(n["default"].SEND_UPDATE_PLAYER_SEASON_LEVEL_INFO, this.getAwardOver, this);
  }, t.prototype.showSeasonInfo = function (e) {
    this.season_index = e, this.node.zIndex = e, this.level_label.string = "" + (this.season_index + 1);
    var t = s["default"].season_info[e];
    this.season_award_info = t, this.general_award_type_node.parent.active = t.award_type.length > 0;

    for (var o = 0; o < 5; o++) {
      this.general_award_type_node.children[o].active = -1 != t.award_type.indexOf(o);
    }

    for (this.general_award_num.string = "" + t.award_num, o = 0; o < 2; o++) {
      if (this.special_award_type_ndoe[o].parent.active = o < t.extra_type.length, this.special_award_type_ndoe[o].parent.active) {
        for (var a = 0; a < 5; a++) {
          this.special_award_type_ndoe[o].children[a].active = t.extra_type[o] == a;
        }

        this.special_award_num[o].string = "" + t.extra_num[o];
      } else this.special_award_num[o].node.active = !1;
    }

    this.getAwardOver();
  }, t.prototype.OnClick = function (t) {
    var o = this;

    switch (e.prototype.OnClick.call(this, t), t.node.name) {
      case "general_get_btn":
        this.getAwardInfo(0);
        break;

      case "special_get_btn":
        l["default"].getInstance().showVideo(function (e) {
          r["default"].playGameBGM(), e == l.ResultEnum.Success && o.getAwardInfo(1);
        });
    }
  }, t.prototype.getAwardInfo = function (e) {
    for (var t = {
      award: 0 == e ? this.season_award_info.award_type : this.season_award_info.extra_type,
      num: 0 == e ? this.season_award_info.award_num : this.season_award_info.extra_num
    }, o = 0; o < t.award.length; o++) {
      var a = t.award[o];
      0 == a ? this.uiManager.addCoinNum(t.num[o]) : 1 == a ? this.uiManager.addZsNum(t.num[o]) : 2 == a ? this.uiManager.addSpNum(t.num[o]) : 3 == a ? this.uiManager.addFhbNum(t.num[o]) : 4 == a && this.uiManager.addTykNum(t.num[o]);
    }

    var n = i.GlobalParams.PlayerSeasonInfo.value;
    0 == e ? n.free_award.push(this.season_index) : n.extra_award.push(this.season_index), i.GlobalParams.PlayerSeasonInfo.value = n, this.getAwardOver();
  }, t.prototype.getAwardOver = function () {
    if (!(this.season_index < 0)) {
      var e = i.GlobalParams.PlayerSeasonInfo.value;
      this.general_mask.active = this.special_mask.active = i.GlobalParams.PlayerInfo.value.level < this.season_index + 1, this.general_get_over.active = -1 != e.free_award.indexOf(this.season_index), this.special_get_over.active = -1 != e.extra_award.indexOf(this.season_index), this.general_get_award_btn.active = !this.general_get_over.active && this.season_award_info.award_type.length > 0, this.special_get_award_btn.active = !this.special_get_over.active, this.red_node.active = !this.general_mask.active;
    }
  }, oo([d(cc.Label)], t.prototype, "level_label", void 0), oo([d(cc.Node)], t.prototype, "general_award_type_node", void 0), oo([d(cc.Label)], t.prototype, "general_award_num", void 0), oo([d(cc.Node)], t.prototype, "general_get_award_btn", void 0), oo([d(cc.Node)], t.prototype, "general_get_over", void 0), oo([d(cc.Node)], t.prototype, "general_mask", void 0), oo([d(cc.Node)], t.prototype, "special_award_type_ndoe", void 0), oo([d(cc.Label)], t.prototype, "special_award_num", void 0), oo([d(cc.Node)], t.prototype, "special_get_award_btn", void 0), oo([d(cc.Node)], t.prototype, "special_get_over", void 0), oo([d(cc.Node)], t.prototype, "special_mask", void 0), oo([d(cc.Node)], t.prototype, "red_node", void 0), oo([c], t);
}(a["default"]);

o["default"] = h;

cc._RF.pop();